home *** CD-ROM | disk | FTP | other *** search
- Path: pop.gnn.com!HoangTQ
- From: Tuyen Hoang <HoangTQ@gnn.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Derived class not calling overloaded base class function
- Date: Sat, 16 Mar 1996 22:33:58
- Organization: GNN
- Message-ID: <4ig150$h3p@news-e2c.gnn.com>
- References: <4g46t2$3vd@otis.netspace.net.au> <4gk310$pqt@nuntius.u-net.net>
- NNTP-Posting-Host: www-29-26.gnn.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset="us-ascii"
- X-GNN-NewsServer-Posting-Date: 17 Mar 1996 03:32:48 GMT
- X-Mailer: GNNmessenger 1.2
-
- First, I want appologize for the previous posting that occured by mistaken setting
- before I finish the.
-
- TorrBoy@Netspace.net.au (Peter J. Torr) wrote:
- >
- >>Hi,
- >
- >>Hopefully a very simple question someone can answer for me!
- >
- >>I have a class, say 'foo' (everyone's favourite) which has a member
- > function
- >>'int Get(void)'
- >
- >>I then derive a class (say 'goo') which has as a base class foo. If goo has
- > a
- >>function also called Get, but with different params (say ''char *Get(char
- > *)') I can't
- >>seem to get the base class' Get() function to operate within the derived
- > class.
- >
- >>If I say just plain "Get()" it says too few parameters (for Get(char *)".
- > If I use
- >>"::Get()" the compiler complains Get should have a prototype. If I say
- > "foo.Get()" it
- >>says improper use of typedef foo. The only way seems to be to explicitly
- > cast the
- >>this pointer to a foo.
- >
- >>Surely there is a better way than this? Thanks for any help (e-mail
- > preferred)
- >
- >>Peter
- >
- In article <4gk310$pqt@nuntius.u-net.net> Thomas Christensen wrote:
-
- >Hi Peter
- >
- >Have you tried foo::Get() ?
-
- Hi Peter
-
- This is an illustration
- goo agoo ;
- agoo.foo::Get(); // the base function foo::get() gets called
-
- If you hate this syntax -I do- and want to use agoo.get() to call the base
- class function, you need to do one *easy* thing: add an inline function into
- your definition of derived class goo
-
- class goo : public foo{
- //...
- void get() { foo::get() ; }
- //...
- };
-
- that's all, but the _concept_is_not_easy_. If you want some explanation, you
- should look back the thread and the FAQ. As my experience, I usually need an
- illustration before I can understand the theorical explanation.
-
- Then this is my question
-
- Do we need a more elegant way than this work around. I wonder to have a way to
- say to the compiler that I do not declare a new function-inlining and calling
- the base function- but notify that the base function is now _unhiding_ from
- the derived overloaded function, something look like
-
- class derived : public base{
- //....
- public:
- void get(int);
- /* unhiding */ void base::get();
- //....
- };
-
- the problem is not concern about one or more overhead calls but the concept
- that the base function is now *explicit* present in the derived class and can
- be overloaded as it was declared here. Does the virtual key word is
- needed/no needed?
-
-
-
- ____________________________________
- Hoang Tuyen Q.
- HoangTQ@gnn.com
-
-